﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Data.Entity.ModelConfiguration.Configuration;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace StevensReceipts.Domain
{
    public class UserPermissionLine : IEntity
    {

        public virtual int UserId { get; set; }
        [ForeignKey("UserId")]
        [JsonIgnore]
        public UserProfile UserProfile { get; set; }

        public virtual int BusinessId { get; set; }
        [ForeignKey("BusinessId")]
        [JsonIgnore]
        public Business Business { get; set; }

        public int PermissionId { get; set; }

        [ForeignKey("PermissionId")]
        [JsonIgnore]
        public Permission Permission { get; set; }

        public DateTime? Created { get; set; }

        public DateTime? Modified { get; set; }
    }


    [Export(typeof(IEntityConfiguration))]
    public class UplEntityTypeConfiguration : EntityTypeConfiguration<UserPermissionLine>, IEntityConfiguration
    {
        public UplEntityTypeConfiguration()
        {
            HasKey(u => new {u.UserId ,u.BusinessId});
            this.ToTable("UserPermissionLine");
        }

        public void AddConfiguration(ConfigurationRegistrar registrar)
        {
            registrar.Add(this);
        }
    }
}
